package com.sfilyh.servelt;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.sql.DataSource;
import org.apache.commons.dbutils.QueryRunner;
import com.sfilyh.util.DBUtil;

@WebServlet(value="/InitConfiguration",loadOnStartup=1)
public class InitConfiguration extends HttpServlet {
	
	private static final long serialVersionUID = 1L;       

    public InitConfiguration() {
        super();
        // 初始化数据连接
		try {
			Context initContext = new InitialContext();
			Context envContext  = (Context)initContext.lookup("java:/comp/env");
	        DataSource ds = (DataSource)envContext.lookup("jdbc/MySqlDB");
	        DBUtil.qr = new QueryRunner(ds);	        
		} catch (NamingException e) {
			e.printStackTrace();
		}
		
	    System.out.println("^_^ system init success!");
		
    }
}
